using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using net_work.Common.Result;
using net_work.IService.ISystem;

namespace net_work.Controllers.System;

[Route("api/[controller]")]
[ApiController]
public class CaptchaController(
    ILogger<CaptchaController> logger,
    ICaptchaService captchaService)
    : ControllerBase
{
    /// <summary>
    /// 生成验证码
    /// </summary>
    /// <returns>CaptchaId和图片</returns>
    [AllowAnonymous]
    [HttpGet("generate")]
    public async Task<IActionResult> GenerateCaptcha()
    {
        logger.LogInformation("生成验证码");

        var captcha = await captchaService.GenerateCaptcha();

        return AjaxResult.Success(captcha);
    }
}